package com.uujava.minibox.gui;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import com.mxcyk.org.插件.截屏.CaptureScreen;
import com.uujava.minibox.ui.button.ImageJButton;
import com.uujava.minibox.ui.panel.ImagePane;
/**
 * 功能：大框架的下部
 * 使用方法：SouthFeet(String path,String imgLeft,String imgRight)
 * @param path 应用列表的所在目录
 * @param imgLeft 设置左按钮的图标
 * @param imgRight 设置右按钮的图标
 * @author k
 * 日期：2012-8-8
 *
 */

final public class South extends ImagePane implements ActionListener{
	Line line_app;//应用列表
	JPanel jpfeet=null;//底部容器控制左右panel
	JPanel jpfeetLeft=null;//底部左边的按钮父容器
	JPanel jpfeetRight=null;//底部右边的按钮父容器
	ImageJButton ijbLeft,ijbRight;//左右按钮
	/**
	 * @param path 应用列表的所在目录
	 * @param imgLeft 设置左按钮的图标
	 * @param imgRight 设置右按钮的图标
	 */
	public South(String path,String imgLeft,String imgRight){
		this.setLayout(new BorderLayout());
		jpfeet=new JPanel(new GridLayout(1,2));//设置底部为表格布局1行2列
		jpfeetLeft=new JPanel(new FlowLayout(FlowLayout.LEFT,0,0));//左对齐在后面还可以加两个参数来控制位置例如：new FlowLayout(FlowLayout.LEFT,0,0)
		jpfeetRight=new JPanel(new FlowLayout(FlowLayout.RIGHT));//右对齐
		
		jpfeet.add(jpfeetLeft);
		jpfeet.add(jpfeetRight);
		left_right_button(jpfeetLeft,jpfeetRight,imgLeft,imgRight);
		line_app=new Line(path,Line.X_AXIS,3,3,20,20);//设置应用列表的路径和按钮的大小
		
		jpfeet.setOpaque(false);
		jpfeetLeft.setOpaque(false);
		jpfeetRight.setOpaque(false);
		
		this.add(line_app,BorderLayout.CENTER);
		this.add(jpfeet,BorderLayout.SOUTH);//底部
		
		//setBackImage("/Skins/ToolBarBackground.png");//设置背景图片
	}

    South(StringBuffer bufferAppend, String imagesreaderpng, String imagesjiePingjpg) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
	
	/**
	 * 功能：设置底部左边按钮&右边按钮
	 * @param jpLeft左边按钮的父容器
	 * @param jpRight右边按钮父容器
	 * @param imgLeft//左边按钮图片
	 * @param imgRight//左边按钮图片
	 */
	private void left_right_button(JPanel jpLeft,JPanel jpRight,String imgLeft,String imgRight){
		ijbLeft=new ImageJButton(imgLeft,30,40);
		ijbRight=new ImageJButton(imgRight,22,24);
		ijbLeft.addActionListener(this);
		ijbRight.addActionListener(this);
		jpLeft.add(ijbLeft);
		jpRight.add(ijbRight);
	}
	

	public static void main(String[] args) {
		String Path = System.getProperty("user.dir");// 获得当前路径
		Path=Path+"/下";
		JFrame jf = new JFrame();
		South sf=new South(Path,"/images/reader.png","/images/xx.gif");
		//sf.setBackImage("/Skins/ToolBarBackground.png");//设置背景图片
		
		
		jf.add(sf);
		jf.setSize(280, 150);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		jf.setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == ijbLeft) {
			System.out.println("点击了左按钮");
		}
		if(e.getSource()==ijbRight){//截屏
			//System.out.println("点击了右按钮");
			jiePing();
		}
		
	}
	/**
	 * 截屏处理方法
	 */
	public void jiePing(){
		new Thread(){
			public void run(){
				CaptureScreen jiePing =new CaptureScreen();
				jiePing=null;
			}
		}.start();
	}
}
